package cn.fzu.panel;

import cn.fzu.frame.StartFrame;
import cn.fzu.util.Tools;

import javax.swing.*;
import javax.swing.border.Border;
import java.awt.*;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;

/**
 * ClassName : cn.fzu.panel.MineState
 * Desc : 状态区
 *
 * @author : LINPQ
 * @date : 2021/3/27 14:40
 */
public class MineState extends JPanel {

    JLabel countB,countS,countG,face,timeB,timeS,timeG;
    StartFrame startFramed;
    public MineState(StartFrame startFrame) {

        this.startFramed = startFrame;

        Border borderIn = BorderFactory.createLoweredBevelBorder();
        Border borderOut = BorderFactory.createEmptyBorder(5, 5, 5, 5);
        Border border = BorderFactory.createCompoundBorder(borderOut, borderIn);
        this.setBorder(border);
        this.setBackground(Color.lightGray);
        this.setLayout(new BorderLayout());

        countB = new JLabel(Tools.iiCount[0]);
        countS = new JLabel(Tools.iiCount[0]);
        countG = new JLabel(Tools.iiCount[0]);
        face = new JLabel(Tools.iiFace[0]);
        timeB = new JLabel(Tools.iiCount[0]);
        timeS = new JLabel(Tools.iiCount[0]);
        timeG = new JLabel(Tools.iiCount[0]);

        face.addMouseListener(new MouseAdapter() {
            @Override
            public void mousePressed(MouseEvent e) {
                int modifiers = e.getModifiers();
                System.out.println(modifiers);
                System.out.println(e.getModifiersEx());
                face.setIcon(Tools.iiFace[1]);
                startFrame.getTimer().start();
            }

            @Override
            public void mouseReleased(MouseEvent e) {
                face.setIcon(Tools.iiFace[0]);
                startFrame.getTimer().stop();
            }

        });


        Box box = Box.createHorizontalBox();
        box.add(Box.createHorizontalStrut(5));
        box.add(countB);
        box.add(countS);
        box.add(countG);
        box.add(Box.createHorizontalGlue());
        box.add(face);
        box.add(Box.createHorizontalGlue());
        box.add(timeB);
        box.add(timeS);
        box.add(timeG);
        box.add(Box.createHorizontalStrut(5));
        add(box);
    }

    public JLabel getCountB() {
        return countB;
    }

    public void setCountB(JLabel countB) {
        this.countB = countB;
    }

    public JLabel getCountS() {
        return countS;
    }

    public void setCountS(JLabel countS) {
        this.countS = countS;
    }

    public JLabel getCountG() {
        return countG;
    }

    public void setCountG(JLabel countG) {
        this.countG = countG;
    }

    public JLabel getFace() {
        return face;
    }

    public void setFace(JLabel face) {
        this.face = face;
    }

    public JLabel getTimeB() {
        return timeB;
    }

    public void setTimeB(JLabel timeB) {
        this.timeB = timeB;
    }

    public JLabel getTimeS() {
        return timeS;
    }

    public void setTimeS(JLabel timeS) {
        this.timeS = timeS;
    }

    public JLabel getTimeG() {
        return timeG;
    }

    public void setTimeG(JLabel timeG) {
        this.timeG = timeG;
    }

    public StartFrame getStartFramed() {
        return startFramed;
    }

    public void setStartFramed(StartFrame startFramed) {
        this.startFramed = startFramed;
    }

    public void setTime(int time){
        timeG.setIcon(Tools.iiCount[time%10]);
    }
}
